﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ins = LEET.StandardModuals.Instructions;
using LEET.CommonInterfaces.TestControls;
using Compiled_Tests;
using System.Windows.Automation;
using LEET.LEETCommon.WidgetLookup;


namespace LEET.StandardModuals.Instructions.Actions
{
    public class Rotate : Ins.Action
    {
        public Rotate(String[] args)
            : base(args)
        {

        }

        public static IAutomationActionResult StaticCall(IBox box, String element, int degrees)
        {
            AutomationElement e = WidgetFinder.Find(element, box.RootElement);
            Object obj;
            e.TryGetCurrentPattern(TransformPattern.Pattern, out obj);
            TransformPattern pattern = obj as TransformPattern;
            if (pattern != null)
                pattern.Rotate(degrees);
            return new AutomationActionResult();
        }

        public override String RenderStaticCall()
        {
            return "LEET.StandardModuals.Instructions.Actions.Rotate.StaticCall(Box, \"" + element + "\", " + args[3] + ")";
        }

        public override string PlainText()
        {
            string amount = args[3];
            string [] split = element.Split(',');
            return "Rotated " + split[split.Length - 1] + " to " + amount + " degrees.";
        }
    }
}
